home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MISC.SWG / 0048_Export data from OBJ file.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-02  |  1KB  |  48 lines

  1. {
  2. WILBERT VAN LEIJEN
  3.  
  4. > I want to pass its address to an external .obj procedure so I can set
  5. > DS:SI to it... how do I do this?  I know how to do this sort of think if I
  6. > use the tp60 built in asmm thingy, and I know that I can pass values using
  7. > arg like
  8.  
  9. You cannot export data from an .OBJ file to a Pascal program.  The linker
  10. cannot handle with public identifiers other than in a segment of class CODE,
  11. alas.
  12.  
  13. Store the data in a File of Byte (DORK.BIN), convert it with BINOBJ to DORK.OBJ
  14. (suggested identifier: Procedure DorkData), link it to your program.
  15. }
  16.  
  17. Procedure DorkData; External;
  18. {$L DORK.OBJ }
  19.  
  20. Type
  21.   TDork = Array[0..255] of Byte;
  22.   PDork = ^TDork;
  23.  
  24. Var
  25.   Dork : PDork;
  26.   i    : Integer;
  27.  
  28. Begin
  29.   Dork := @DorkData;
  30.   For i := Low(TDork) to High(TDork) Do
  31.     Write(Dork^[i] : 4);
  32. end.
  33.  
  34. { If you want to use assembler to access DorkData: }
  35.  
  36. ASM
  37.   CLD
  38.   PUSH   DS
  39.   PUSH   CS            { Using "LDS SI, DorkData" will not work! }
  40.   POP    DS
  41.   LEA    SI, DorkData            { DS:SI points to DorkData }
  42.   MOV    CX, Type(TDork)         { = 256 }
  43.  @1:     LODSB                { TDork(DorkData[256-CX]) is now in AL }
  44.   { other code }
  45.   LOOP   @1
  46.   POP    DS
  47. end;
  48.